from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
import time
import subprocess


#browser = webdriver.Chrome() # Get local session of firefox
'''browser = webdriver.Remote(
   command_executor='http://127.0.0.1:4444/wd/hub',
   desired_capabilities={'browserName':'internet explorer',
     'version':'9',
                         })'''
#browser = webdriver.Ie()
#browser.add_cookie(c)
#browser.get_cookies()
#browser.get("http://shop.tcy365.org:1505/")
#browser.refresh()
#browser.find_element_by_link_text('提交内容').click()

#cmd = "adb shell am start -W io.selendroid.androiddriver/.WebViewActivity"
#subprocess.Popen(cmd,shell=True)
def cmdexe(cmd):
	p = subprocess.Popen(cmd,shell=True)
	p.communicate()

def screenshot(path):
	cmd1 = 'adb shell /system/bin/screencap -p /sdcard/screenshot.png'
	cmd2 = 'adb pull /sdcard/screenshot.png {0}.png'.format(path)
	cmdexe(cmd1)
	cmdexe(cmd2)

time.sleep(2)

browser = webdriver.Remote(desired_capabilities={'browserName':'android'})

browser.get("http://activitysupport.tcysys.uc108.net/Static/SpecialAct/Common/20171201/")
screenshot('1')
Select(browser.find_element_by_id("vux-x-input-idCard")).select_by_index(1)
screenshot('2')
screenshot('3')
screenshot('4')
browser.quit()




